<?php
class Url {
	var $module = '';
	var $action = '';
	var $values;
	function __construct() {
		if (isset ( $_SERVER ['PATH_INFO'] )) {
			$pathinfo = explode ( "/", substr ( $_SERVER ['PATH_INFO'], 1 ) );
			$this->module = array_shift ( $pathinfo );
			$this->action = array_shift ( $pathinfo );
			if (isset ( $_POST )) {
				$pathinfo = $_POST;
			}
			foreach ( $pathinfo as $key => $value ) {
				$this->values [$key] = addslashes ( $value );
			}
		}
	}
	function getModule() {
		return $this->module;
	}
	function getAction() {
		return $this->action;
	}
	function getValues() {
		return $this->values;
	}
	function getParam() {
		$param = array ();
		foreach ( $this->getValues () as $key => $value ) {
			$param [$key] = addslashes ( $value );
		}
		return $param;
	}
	function base() {
		return 'http://' . $_SERVER ['HTTP_HOST'];
	}
	function site($uri = '', $index = FALSE, $protocol = FALSE) {
		$rul = explode ( '/', $uri );
		$index = $index ? "index.php" : array_shift ( $rul );
		$path = array_shift ( $rul );
		if (! empty ( $path ))
			$path = '/' . $path;
		return url::base ( TRUE, $protocol ) . TRGPHP_PATH . $index . $path;
	}
}
?>